package com.calvin.study.proxy.dynamicproxy;

//https://zhuanlan.zhihu.com/p/161620305
public class Client {
	
	public static void main(String[] args) {
		try {
			//创建目标对象
			ICustomer cust =  new CustomerA();
			
			//给目标对象创建代理对象
			ICustomer  proxyInstance = (ICustomer) new FangWuZhongJieProxy(cust).getProxyInstance();
			System.out.println("proxyInstance: " + proxyInstance);
			//内存中动态创建的代理对象
			System.out.println("proxyInstance: " + proxyInstance.getClass());
			
			//通过代理对象调用目标对象方法
			proxyInstance.findRoom();
			
			System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
